package com.wgts.wgts.mvp.presenter.imp;

import com.wgts.wgts.mvp.model.IPayResultModel;
import com.wgts.wgts.mvp.presenter.IPayResultPresenter;
import com.wgts.wgts.mvp.view.IPayResultView;
import com.wgts.wgts.netmodle.HttpResultSubscriber;
import com.wgts.wgts.netmodle.req.SearchShopListRequest;
import com.wgts.wgts.netmodle.resp.CurrentEntity;
import com.wgts.wgts.netmodle.resp.SearchShopResultEntity;

/*
 *
 *
 *   data:2018/10/2213:48
 *
 */public class PayResultPresenter implements IPayResultPresenter {
     private IPayResultView view;
     private IPayResultModel model;
     private int pageIndex = 1;
     private int pageSize = 20;

    public PayResultPresenter(IPayResultView view, IPayResultModel model) {
        this.view = view;
        this.model = model;
    }

    @Override
    public void initList() {
        pageIndex = 1;
        SearchShopListRequest request = new SearchShopListRequest();
        request.pageIndex = pageIndex;
        request.pageSize = pageSize;
        request.recommend = "1";
        model.initList(request, new HttpResultSubscriber<SearchShopResultEntity>() {
            @Override
            public void onSuccess(SearchShopResultEntity entity) {
                if (entity.list.size() < pageSize){
                    view.initList(entity, true);
                }else {
                    view.initList(entity, false);
                    pageIndex++;
                }
            }

            @Override
            public void _onError(int status, String msg) {

            }
        });
    }

    @Override
    public void loadMore() {
        SearchShopListRequest request = new SearchShopListRequest();
        request.pageIndex = pageIndex;
        request.pageSize = pageSize;
        request.recommend = "1";
        model.initList(request, new HttpResultSubscriber<SearchShopResultEntity>() {
            @Override
            public void onSuccess(SearchShopResultEntity entity) {
                if (entity.list.size() < pageSize){
                    view.loadMore(entity, true);
                }else {
                    view.loadMore(entity, false);
                    pageIndex++;
                }
            }

            @Override
            public void _onError(int status, String msg) {

            }
        });
    }

    @Override
    public void affirmAlipay(String orderCode, String payType) {
        model.affitmAlipay(orderCode, payType, new HttpResultSubscriber<CurrentEntity>() {
            @Override
            public void onSuccess(CurrentEntity currentEntity) {
                
            }

            @Override
            public void _onError(int status, String msg) {

            }
        });
    }
}
